 " Smart way to move between windows
 map <C-j> <C-W>j
 map <C-k> <C-W>k
 map <C-h> <C-W>h
 map <C-l> <C-W>l

 " Close the current buffer
 map <leader>bd :bdelete<cr>
 map <leader>bn :bnext<cr>
 map <leader>bp :bprevious<cr>

" " Useful mappings for managing tabs
 map <leader>tn :tabnew<cr>
" map <leader>to :tabonly<cr>
 map <leader>tc :tabclose<cr>
" map <leader>tm :tabmove
" map <leader>t  :tabnext<cr>
"

 nnoremap <F2> :set nu! nu?<CR>



" ctrlp {
     if isdirectory(expand("~/.config/nvim/plugged/ctrlp.vim/"))
         let g:ctrlp_working_path_mode = 'ra'
         nnoremap <silent> <D-t> :CtrlP<CR>
         nnoremap <silent> <D-r> :CtrlPMRU<CR>
         let g:ctrlp_custom_ignore = {
             \ 'dir':  '\.git$\|\.hg$\|\.svn$',
             \ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }

         if executable('ag')
             let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""'
         elseif executable('ack-grep')
             let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
         elseif executable('ack')
             let s:ctrlp_fallback = 'ack %s --nocolor -f'
         " On Windows use "dir" as fallback command.
         else
             let s:ctrlp_fallback = 'find %s -type f'
         endif
         if exists("g:ctrlp_user_command")
             unlet g:ctrlp_user_command
         endif
         let g:ctrlp_user_command = {
             \ 'types': {
                 \ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
                 \ 2: ['.hg', 'hg --cwd %s locate -I .'],
             \ },
             \ 'fallback': s:ctrlp_fallback
         \ }

         if isdirectory(expand("~/.config/nvim/plugged/ctrlp-funky/"))
             " CtrlP extensions
             let g:ctrlp_extensions = ['funky']

             "funky
             nnoremap <Leader>fu :CtrlPFunky<Cr>
         endif
     endif
 "}

" UndoTree {
   if isdirectory(expand("~/.config/nvim/plugged/undotree/"))
       nnoremap <Leader>p :UndotreeToggle<CR>
       " If undotree is opened, it is likely one wants to interact with it.
       let g:undotree_SetFocusWhenToggle=1
   endif
  " }

"EasyMotion{
  let g:EasyMotion_smartcase = 1
  "let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
  map <Leader><leader>h <Plug>(easymotion-linebackward)
  map <Leader><Leader>j <Plug>(easymotion-j)
  map <Leader><Leader>k <Plug>(easymotion-k)
  map <Leader><leader>l <Plug>(easymotion-lineforward)
  " 重复上一次操作, 类似repeat插件, 很强大  
  map <Leader><leader>. <Plug>(easymotion-repeat)
"}"


"ctrlp{
   nnoremap <Leader>fu :CtrlPFunky<Cr>
   " narrow the list down with a word under cursor
   nnoremap <Leader>fU :execute 'CtrlPFunky ' . expand('<cword>')<Cr>
   let g:ctrlp_funky_syntax_highlight = 1

   let g:ctrlp_extensions = ['funky']
"}


" bufferline
" These commands will navigate through buffers in order regardless of which mode you are using
" e.g. if you change the order of buffers :bnext and :bprevious will not respect the custom ordering
nnoremap <silent>[b :BufferLineCycleNext<CR>
nnoremap <silent>b] :BufferLineCyclePrev<CR>



"选择屏幕上的第几个缓冲区
nnoremap <silent><leader>1 <Cmd>BufferLineGoToBuffer 1<CR>
nnoremap <silent><leader>2 <Cmd>BufferLineGoToBuffer 2<CR>
nnoremap <silent><leader>3 <Cmd>BufferLineGoToBuffer 3<CR>
nnoremap <silent><leader>4 <Cmd>BufferLineGoToBuffer 4<CR>
nnoremap <silent><leader>5 <Cmd>BufferLineGoToBuffer 5<CR>
nnoremap <silent><leader>6 <Cmd>BufferLineGoToBuffer 6<CR>
nnoremap <silent><leader>7 <Cmd>BufferLineGoToBuffer 7<CR>
nnoremap <silent><leader>8 <Cmd>BufferLineGoToBuffer 8<CR>
nnoremap <silent><leader>9 <Cmd>BufferLineGoToBuffer 9<CR>


"选择缓冲区
nnoremap <silent> gb :BufferLinePick<CR>


















